﻿using System;
using System.Text;
using ThoughtWorks.QRCode.Codec;
using System.Drawing;

namespace WebApplication5
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            create_two(this.TextBox1.Text);
           

        }

        private void create_two(string nr)
        {
            Bitmap bt;
            string enCodeString = nr;
            QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
            bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);
            string filename = Guid.NewGuid().ToString() + ".jpg";
            filename = filename.Replace(" ", "");
            filename = filename.Replace(":", "");
            filename = filename.Replace("-", "");
            filename = filename.Replace(".", "");
            bt.Save(Server.MapPath("~/image/") + filename + ".jpg");
            this.Image1.ImageUrl = "~/image/" + filename + ".jpg";
        }
    }
}